import { ShowGuideData } from './../define/GuideData';
import { CompositeDisposable } from "../../../../framework/event/EventKit";
import { ViewBackState, ViewLayer, ViewMode } from "../../../../framework/view/ViewConsts";
import { ViewCtrlBase } from "../../../../framework/view/ViewCtrlBase";
import { GameGuideEvent } from "../define/GuideEvents";
import ViewGuide from "../view/ViewGuide";
import ModelGuide from '../model/ModelGuide';


export default class VCGuide extends ViewCtrlBase {
    public static viewName: string = "ViewGuide";
    public static viewMode: ViewMode = ViewMode.SINGLE;
    public viewLayer: ViewLayer = ViewLayer.Layer_Guide;
    public viewClass: (typeof ViewGuide) = ViewGuide;

    public model:ModelGuide = ModelGuide.getInstance() as ModelGuide;
    onOpen(){
        super.onOpen();
    }

    onClose(){
        super.onClose();
    }
    /**注册系统事件 */
    registEvent(): void {
        this.disposable = new CompositeDisposable();
        this.disposable.add(GameGuideEvent.ON_BLOCK_ALL.on(this.blockAll.bind(this)));
        this.disposable.add(GameGuideEvent.ON_PASS_ALL.on(this.passAll.bind(this)));
        this.disposable.add(GameGuideEvent.ON_GUIDE_SHOW.on(this.showGuide.bind(this)));
    }

    /**
     * @desc 检查是否可以使用返回键退出
     * 特殊情况,子类重写方法逻辑,返回ViewBackState.Close则不可以使用返回键关闭
     * @returns ViewBackState
     */
     public checkCanBack():ViewBackState{
        if (this.model.isShowing) {
            return ViewBackState.Return;           
        }
        return ViewBackState.Pass;
    }

    showGuide(data:ShowGuideData){
        this.viewDoAction("showGuide",data);
    }

     /**放行所有点击 */
     public passAll() {
        this.viewDoAction("passAll");
    }

    //**屏蔽所有点击 */
    public blockAll() {
        this.viewDoAction("blockAll");

    }
}